﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Services;
using IntelligentAgriculture.WebAPI.Application.Command.PersonalDetailsCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.PersonalDetailsCommandHandler
{
    public class UpdatePassWordCommandHandler : IRequestHandler<UpdatePassWordCommand, Results<int>>
    {
        private readonly IPersonalSettingService _personalSettingService;

        public UpdatePassWordCommandHandler(IPersonalSettingService personalSettingService)
        {
            _personalSettingService = personalSettingService;
        }

        public async Task<Results<int>> Handle(UpdatePassWordCommand request, CancellationToken cancellationToken)
        {
            var ints = await _personalSettingService.UpdatePassWord(request.OldPassword, request.NewPassword);
            return Results<int>.DataResult(ints);
        }
    }
}
